#!/bin/bash
file_name=functions.sh
funcs=`which $file_name`
if [ "$funcs" != "" ] ;then
  echo "funcs=$funcs"
  . $funcs
else
  funcs=`dirname $0`/$file_name
  echo "$PWD"
  echo "funcs=$funcs"
  if [ "$funcs" != "" ] ;then
    . $funcs
  else
    exit
  fi
fi

function showHelp()
{
	echoTextRed “使用方法如下”
	echoTextRed "1、检出一份完整的app仓代码"
	echoTextRed "2、$0 -d app仓本地文件夹 -p 项目名"
	exit
}

#脚本入口
while test $# != 0
do
    case $1 in
   	-d)
	    shift
	    directory=$1
	    ;;
   	-p)
	    shift
	    project_name=$1
	    ;;
	--help | --h)
		shift
		showHelp
		;;
    *)
	   	directory=$1
	   	;;
    esac
       shift
done

if [ -z "$directory" ];then
	directory=`pwd`
fi
configed=
unconfiged=

if [ -z "$project_name" ];then
	showHelp
fi

echo "directory=$directory"
echo "project_name=$project_name"

aaa=`find $directory -name "release.xml"`
for i in $aaa;do
	result=`cat $i | grep -w $project_name`
	if [ -n "$result" ];then
		configed="$configed $i"
	else
		unconfiged="$unconfiged $i"
	fi
done

echoTextBlue "已配置项目$project的xml文件：$configed"
echoTextCyan "未配置项目$project的xml文件：$unconfiged"






